import http from './http.js'
import api from './api.js';
//注册
export function register(data) {
    // return http.post(api.registerApi, data)
    return http({
        method: 'POST',
        url: api.registerApi,
        data: data,
    })

}
//登录
export function login(data) {
    // return http.post(api.loginApi, data)
    return http({
        method: 'POST',
        url: api.loginApi,
        data: data,
    })
}
//退出登录
export function loginOut() {
    // return http.post(api.loginApi, data)
    return http({
        method: 'POST',
        url: api.loginOutApi,
    })
}
//获取商品列表
export function getGoods(data) {
    // return http.get(api.getGoodsApi, data)
    return http({
        method: 'GET',
        url: api.getGoodsApi,
        params: data
    })
}
//获取轮播图
export function carousel() {
    return http({
        method: 'GET',
        url: api.carouselApi,
        params: {
            "project_id": 13,
        }
    })
}
//获取购物车
export function getCart() {
    return http({
        method: 'GET',
        url: api.cartApi,
        params: {
            "project_id": 13,
        }
    })
}
//添加购物车
export function addCart(data) {
    return http({
        method: 'POST',
        url: api.cartApi,
        data: data
    })
}
//更新购物车单条信息
export function updateCart(id, data) {
    return http({
        method: 'PUT',
        url: api.cartApi + `/${id}`,
        data: data,
    })
}
//删除购物车一条信息
export function delCart(id) {
    return http({
        method: 'DELETE',
        url: api.cartApi + `/${id}`,
    })
}
//获取用户信息
export function getUser() {
    return http({
        method: 'GET',
        url: api.userApi,
    })
}
//下单
export function order(data) {
    return http({
        method: 'POST',
        url: api.orderApi,
        data: data
    })
}
//获取订单列表
export function getPay() {
    return http({
        method: 'GET',
        url: api.orderApi,
        params: {
            project_id: 13,
            status: '-1,0,1,2,3,4,5,6,7',
        }
    })
}
//获取订单详情
export function getPayDetail(id) {
    return http({
        method: 'GET',
        url: api.orderApi + '/' + id
    })
}
//取消订单
export function cancel(id) {
    return http({
        method: 'PUT',
        url: api.orderApi + '/' + id,
        data: {
            "status": "7"
        }
    })
}
//删除订单
export function delOrder(id) {
    return http({
        method: 'DELETE',
        url: api.orderApi + '/' + id,
    })
}
//获取所有城市
export function getCity() {
    return http({
        method: 'GET',
        url: api.cityApi,
    })
}
//添加收货地址
export function addAddress(data) {
    return http({
        method: 'POST',
        url: api.addressApi,
        data: data
    })
}
//获取地址列表
export function getAddress() {
    return http({
        method: 'GET',
        url: api.addressApi,
    })
}
//删除地址
export function delAddress(id) {
    return http({
        method: 'DELETE',
        url: api.addressApi + `/${id}`,
    })
}
//更新地址
export function updateAddress(id, data) {
    return http({
        method: 'PUT',
        url: api.addressApi + `/${id}`,
        data: data,
    })
}
//默认地址
export function setDefault(id) {
    return http({
        method: 'POST',
        url: api.setDefaultApi + `/${id}`,
    })
}
